Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SuperKeyboard] - Created a keyboard plugin #2474

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

matthew-carroll
Copy link
Contributor

@matthew-carroll matthew-carroll commented Dec 22, 2024

[SuperKeyboard] - Created a keyboard plugin.

The plugin reports four keyboard states on Android and iOS: closed, opening, open, closing.

The Android implementation also reports the keyboard height.

This plugin was created to provide more dependable knowledge about keyboard state for Super Editor's chat scaffold.

This PR moves Super Editor's test keyboard simulator into the new keyboard package. A followup PR will remove it from super_editor.

@matthew-carroll
Copy link
Contributor Author

@angelosilvestre I'm gonna merge this so that I can create an initial release and use it in super_editor. Please feel free to leave comments that we can handle in followup.

Copy link
Collaborator

@angelosilvestre angelosilvestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some comments.


private var channel: FlutterMethodChannel?

// private var displayLink: CADisplayLink?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the commented lines.

Comment on lines +34 to +39
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
default:
result(FlutterMethodNotImplemented)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add a comment here explaining that we don't handle any methods from Flutter because all events come from the platform.

import 'package:logging/logging.dart';
import 'package:super_keyboard/src/keyboard.dart';

class SuperKeyboardAndroidBuilder extends StatefulWidget {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a dart doc.

}
}

class SuperKeyboardAndroid {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a dart doc explaining how to use it.

import 'package:logging/logging.dart';
import 'package:super_keyboard/src/keyboard.dart';

class SuperKeyboardIOSBuilder extends StatefulWidget {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a dart doc.

}
}

class SuperKeyboardIOS {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a dart doc explaining how to use it.

import 'package:super_keyboard/src/super_keyboard_android.dart';
import 'package:super_keyboard/src/super_keyboard_ios.dart';

class SuperKeyboardBuilder extends StatefulWidget {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a dart doc.

Comment on lines +75 to +84
void _init() {
log.info("Initializing SuperKeyboard");
if (defaultTargetPlatform == TargetPlatform.iOS) {
log.fine("SuperKeyboard - Initializing for iOS");
SuperKeyboardIOS.instance.keyboardState.addListener(_onIOSKeyboardChange);
} else if (defaultTargetPlatform == TargetPlatform.android) {
log.fine("SuperKeyboard - Initializing for Android");
SuperKeyboardAndroid.instance.keyboardState.addListener(_onAndroidKeyboardChange);
SuperKeyboardAndroid.instance.keyboardHeight.addListener(_onAndroidKeyboardHeightChange);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log something if this is used in another platform?

Comment on lines +115 to +116
case TargetPlatform.android:
tester.view.physicalSize = const Size(1170, 2532); // iPhone 13 Pro
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to reset this value when the test finishes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants